package com.qit.prototype.flink.processor;

import java.util.Random;

import com.qit.prototype.flink.entity.MarketData;
import com.qit.prototype.flink.entity.Tick;

public class MarketDataConvertJob implements IMarketDataConvertJob {

	@Override
	public MarketData execute(Tick tick, int parallelIndex) {
		int i = 0;
		while (i < 5000) {
			Random r = new Random(10000);
			r.nextInt();
			i++;
		}
		
		MarketData md = new MarketData(tick.getSymbol(), MarketData.FIELD_GROUP_TRADE);
		md.setId(tick.getId());
		md.getFieldValues().put("price", String.valueOf(tick.getPrice()));
		md.getFieldValues().put("qty", String.valueOf(tick.getQty()));
		return md;
	}

}
